<?php


namespace App\Model;


use HyperfExt\Auth\Authenticatable;
use HyperfExt\Auth\Contracts\AuthenticatableInterface;
use HyperfExt\Hashing\Hash;
use HyperfExt\Jwt\Contracts\JwtSubjectInterface;

class User extends Model implements JwtSubjectInterface,AuthenticatableInterface
{
    use Authenticatable;

    protected $fillable = ['phone', 'name', 'password', 'nickname'];

    public function setPasswordAttribute($value)
    {
        $this->attributes['password'] = Hash::make($value);
    }

    public function getJwtCustomClaims(): array
    {
        return [
            'guard' => 'api'    // 添加自定义信息
        ];
    }

    public function getJwtIdentifier()
    {
        return $this->getKey();
    }

}